﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for PhotosDAL
/// </summary>
public class PhotosDAL: StandardConnectDB, IPhotos
{
	public PhotosDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public List<Photos> GetListPhotosOfAlbum(Albums album)
    {

        List<Photos> listphoto = new List<Photos>();

        Dictionary<String, Object> paramList = new Dictionary<String, Object>();


        paramList.Add("@pIdAlbum", album.IdAlbum);

        DataTable dt = this.DTExecuteSelect("spGetListPhotosOfAlbum", paramList);

        foreach (DataRow dr in dt.Rows)
        {
            listphoto.Add(this.ConvertoPhotos(dr));
        }


        return listphoto;

       
    }

    public Photos GetPhotoById(int idPhoto)
    {
        Photos photo = new Photos();

        Dictionary<String, Object> paramList = new Dictionary<String, Object>();

        //Add parameter pIdRole to paramList
        paramList.Add("@pIdPhoto", idPhoto);

        //Get Users by store procedure
        DataTable dt = this.DTExecuteSelect("spGetPhotoById", paramList);

        
        if (dt.Rows.Count == 1)
        {
            DataRow dr = dt.Rows[0];

            photo = ConvertoPhotos(dr);
        }
            return photo;
    }

    public Photos GetPhotoByName(string name)
    {
        throw new NotImplementedException();
    }

    public bool CreatePhoto(string name, string description, string photoLocation, Albums album)
    {
        throw new NotImplementedException();
    }

    public bool DeletePhoto(Photos photo)
    {
        throw new NotImplementedException();
    }

    public bool UpdatePhoto(Photos photo)
    {
        throw new NotImplementedException();
    }
    public Photos ConvertoPhotos(DataRow dr)
    {
        Photos p = new Photos();
        p.PhotoLocation = dr["PhotoLocation"].ToString();
        return p;
    }
}